module frv_store_queue (
    input                       clk,    // Clock
    input                       clk_en, // Clock Enable
    input                       rst_n,  // Asynchronous reset active low

    output                      RAW_flag,
    output[31:0]                RAW_load_data,

    input                       lsu_req         ,
    input                       lsu_ctrl_unsign ,
    input                       lsu_ctrl_load   ,
    input                       lsu_ctrl_store  ,
    input                       lsu_ctrl_word   ,
    input                       lsu_ctrl_half   ,
    input                       lsu_ctrl_byte   ,
    input [5:0]     lsu_inst_id     , // Instruction ID
    input                       lsu_flush       ,
    input [5:0]     lsu_flush_id    ,
    input                       retire_vld      ,
    input                       lsu_load_ready  ,
    output                      lsu_store_ready ,
    //LSU Operation Number
    input [31:0]                lsu_op1_val     ,
    input [31:0]                lsu_op2_val     ,
    input [31:0]                lsu_store_data  ,
    //cache store
    output                      dmem_store_req        ,
    output [5:0]    dmem_store_req_tid    , // request transaction id , ignore it before we implement cache
    output [31:0]               dmem_store_addr       , 
    output [31:0]               dmem_store_wdata      ,
    input                       dmem_store_ack        , // Cache will give ACK to LSU if cache hit happen
    input                       dmem_store_hit        ,
    output                      dmem_store_flush      ,
    output [3-1:0]              dmem_store_info       ,
    //ddr store
    output                      ddr_store_req         ,
    output [5:0]    ddr_store_req_tid     , // request transaction id , ignore it before we implement cache
    output [31:0]               ddr_store_addr        ,
    output [31:0]               ddr_store_wdata       ,
    input                       ddr_store_ack         ,
    input [5:0]     ddr_store_ack_tid     ,
    //store resp 
    output [5:0]    store_resp_inst_id    ,
    output                      store_resp_vld        ,
    output                      store_resp_rd_vld     ,
    output [5:0]                store_resp_rd_ind     ,
    output [31:0]               store_resp_rd_val     ,
    output                      store_exp_vld         ,
    input                       load_resp_vld         ,
    //dev store
        //waddr ch
    // output [5:0]    dev_awtid       ,
    output [31:0]               dev_awaddr      ,
    output [2:0]                dev_awprot      ,
    output                      dev_awvalid     ,
    input                       dev_awready     ,
        //wdata ch 
    output [31:0]               dev_wdata       ,
    output [3:0]                dev_wstrb       ,
    output                      dev_wvalid      ,
    input                       dev_wready      ,
        //b resp ch
    input  [1:0]                dev_bresp       ,
    input                       dev_bvalid      ,
    output                      dev_bready      


);

assign store_req        =lsu_req & lsu_ctrl_store & lsu_store_ready & lsu_load_ready;
assign lsu_req_type     =((lsu_op2_val+lsu_op1_val)>32'h8000_0000)?1'b1:1'b0;

// wire [16-1:0]               entry_WAW_select                                                   ;
// wire [16-1:0]               entry_WAW_select_shift     = (entry_WAW_select & 2**(tail_ptr+1)-1)>>1  ;
// assign               store_WAW_selected        = rreq?entry_WAW_select_shift:entry_WAW_select;

//entrys output
wire [32-1:0]                entry_req_addr_o_0       ;
wire [5+1-1:0]   entry_req_id_o_0         ;
wire [1-1:0]                 entry_vld_o_0            ;
wire [4-1:0]                 entry_req_state_o_0      ;
wire [1-1:0]                 entry_req_type_o_0       ;
wire [32-1:0]                entry_store_data_o_0     ;
wire                         entry_store_tag_o_0      ;
wire [3-1:0]                 entry_req_info_o_0       ;
wire [32-1:0]                entry_req_addr_o_1       ;
wire [5+1-1:0]   entry_req_id_o_1         ;
wire [1-1:0]                 entry_vld_o_1            ;
wire [4-1:0]                 entry_req_state_o_1      ;
wire [1-1:0]                 entry_req_type_o_1       ;
wire [32-1:0]                entry_store_data_o_1     ;
wire                         entry_store_tag_o_1      ;
wire [3-1:0]                 entry_req_info_o_1       ;
wire [32-1:0]                entry_req_addr_o_2       ;
wire [5+1-1:0]   entry_req_id_o_2         ;
wire [1-1:0]                 entry_vld_o_2            ;
wire [4-1:0]                 entry_req_state_o_2      ;
wire [1-1:0]                 entry_req_type_o_2       ;
wire [32-1:0]                entry_store_data_o_2     ;
wire                         entry_store_tag_o_2      ;
wire [3-1:0]                 entry_req_info_o_2       ;
wire [32-1:0]                entry_req_addr_o_3       ;
wire [5+1-1:0]   entry_req_id_o_3         ;
wire [1-1:0]                 entry_vld_o_3            ;
wire [4-1:0]                 entry_req_state_o_3      ;
wire [1-1:0]                 entry_req_type_o_3       ;
wire [32-1:0]                entry_store_data_o_3     ;
wire                         entry_store_tag_o_3      ;
wire [3-1:0]                 entry_req_info_o_3       ;
wire [32-1:0]                entry_req_addr_o_4       ;
wire [5+1-1:0]   entry_req_id_o_4         ;
wire [1-1:0]                 entry_vld_o_4            ;
wire [4-1:0]                 entry_req_state_o_4      ;
wire [1-1:0]                 entry_req_type_o_4       ;
wire [32-1:0]                entry_store_data_o_4     ;
wire                         entry_store_tag_o_4      ;
wire [3-1:0]                 entry_req_info_o_4       ;
wire [32-1:0]                entry_req_addr_o_5       ;
wire [5+1-1:0]   entry_req_id_o_5         ;
wire [1-1:0]                 entry_vld_o_5            ;
wire [4-1:0]                 entry_req_state_o_5      ;
wire [1-1:0]                 entry_req_type_o_5       ;
wire [32-1:0]                entry_store_data_o_5     ;
wire                         entry_store_tag_o_5      ;
wire [3-1:0]                 entry_req_info_o_5       ;
wire [32-1:0]                entry_req_addr_o_6       ;
wire [5+1-1:0]   entry_req_id_o_6         ;
wire [1-1:0]                 entry_vld_o_6            ;
wire [4-1:0]                 entry_req_state_o_6      ;
wire [1-1:0]                 entry_req_type_o_6       ;
wire [32-1:0]                entry_store_data_o_6     ;
wire                         entry_store_tag_o_6      ;
wire [3-1:0]                 entry_req_info_o_6       ;
wire [32-1:0]                entry_req_addr_o_7       ;
wire [5+1-1:0]   entry_req_id_o_7         ;
wire [1-1:0]                 entry_vld_o_7            ;
wire [4-1:0]                 entry_req_state_o_7      ;
wire [1-1:0]                 entry_req_type_o_7       ;
wire [32-1:0]                entry_store_data_o_7     ;
wire                         entry_store_tag_o_7      ;
wire [3-1:0]                 entry_req_info_o_7       ;
wire [32-1:0]                entry_req_addr_o_8       ;
wire [5+1-1:0]   entry_req_id_o_8         ;
wire [1-1:0]                 entry_vld_o_8            ;
wire [4-1:0]                 entry_req_state_o_8      ;
wire [1-1:0]                 entry_req_type_o_8       ;
wire [32-1:0]                entry_store_data_o_8     ;
wire                         entry_store_tag_o_8      ;
wire [3-1:0]                 entry_req_info_o_8       ;
wire [32-1:0]                entry_req_addr_o_9       ;
wire [5+1-1:0]   entry_req_id_o_9         ;
wire [1-1:0]                 entry_vld_o_9            ;
wire [4-1:0]                 entry_req_state_o_9      ;
wire [1-1:0]                 entry_req_type_o_9       ;
wire [32-1:0]                entry_store_data_o_9     ;
wire                         entry_store_tag_o_9      ;
wire [3-1:0]                 entry_req_info_o_9       ;
wire [32-1:0]                entry_req_addr_o_10       ;
wire [5+1-1:0]   entry_req_id_o_10         ;
wire [1-1:0]                 entry_vld_o_10            ;
wire [4-1:0]                 entry_req_state_o_10      ;
wire [1-1:0]                 entry_req_type_o_10       ;
wire [32-1:0]                entry_store_data_o_10     ;
wire                         entry_store_tag_o_10      ;
wire [3-1:0]                 entry_req_info_o_10       ;
wire [32-1:0]                entry_req_addr_o_11       ;
wire [5+1-1:0]   entry_req_id_o_11         ;
wire [1-1:0]                 entry_vld_o_11            ;
wire [4-1:0]                 entry_req_state_o_11      ;
wire [1-1:0]                 entry_req_type_o_11       ;
wire [32-1:0]                entry_store_data_o_11     ;
wire                         entry_store_tag_o_11      ;
wire [3-1:0]                 entry_req_info_o_11       ;
wire [32-1:0]                entry_req_addr_o_12       ;
wire [5+1-1:0]   entry_req_id_o_12         ;
wire [1-1:0]                 entry_vld_o_12            ;
wire [4-1:0]                 entry_req_state_o_12      ;
wire [1-1:0]                 entry_req_type_o_12       ;
wire [32-1:0]                entry_store_data_o_12     ;
wire                         entry_store_tag_o_12      ;
wire [3-1:0]                 entry_req_info_o_12       ;
wire [32-1:0]                entry_req_addr_o_13       ;
wire [5+1-1:0]   entry_req_id_o_13         ;
wire [1-1:0]                 entry_vld_o_13            ;
wire [4-1:0]                 entry_req_state_o_13      ;
wire [1-1:0]                 entry_req_type_o_13       ;
wire [32-1:0]                entry_store_data_o_13     ;
wire                         entry_store_tag_o_13      ;
wire [3-1:0]                 entry_req_info_o_13       ;
wire [32-1:0]                entry_req_addr_o_14       ;
wire [5+1-1:0]   entry_req_id_o_14         ;
wire [1-1:0]                 entry_vld_o_14            ;
wire [4-1:0]                 entry_req_state_o_14      ;
wire [1-1:0]                 entry_req_type_o_14       ;
wire [32-1:0]                entry_store_data_o_14     ;
wire                         entry_store_tag_o_14      ;
wire [3-1:0]                 entry_req_info_o_14       ;
wire [32-1:0]                entry_req_addr_o_15       ;
wire [5+1-1:0]   entry_req_id_o_15         ;
wire [1-1:0]                 entry_vld_o_15            ;
wire [4-1:0]                 entry_req_state_o_15      ;
wire [1-1:0]                 entry_req_type_o_15       ;
wire [32-1:0]                entry_store_data_o_15     ;
wire                         entry_store_tag_o_15      ;
wire [3-1:0]                 entry_req_info_o_15       ;

//select ctrl signals
//      head is always selected
wire [16-1:0]               retire_vld_selected  =retire_vld?1:0;
wire [16-1:0]               store_cache_selected = entry_req_state_o_0==2 & entry_req_type_o_0 ==1;
wire [16-1:0]               store_cache_miss     = dmem_store_ack?~dmem_store_hit:0;
wire [16-1:0]               store_cache_hit      = dmem_store_ack?dmem_store_hit:0;
wire [16-1:0]               store_ddr_selected   = entry_req_state_o_0==5;
wire [16-1:0]               store_ddr_ack        = ddr_store_ack;
wire [16-1:0]               store_dev_selected   = (entry_req_state_o_0==2 & entry_req_type_o_0 ==0) | (entry_req_state_o_0==4);
wire                store_dev_awready    = entry_req_state_o_0==7;
wire                store_dev_wready     = entry_req_state_o_0==8;
wire [16-1:0]               store_WAW_selected   =0;
wire [16-1:0]               dev_store_awready    =dev_awready?1:0;
wire [16-1:0]               dev_store_wready     =dev_wready?1:0;
wire [16-1:0]               dev_store_bvalid     =dev_bvalid?1:0;
wire [16-1:0]               store_resp_selected  =entry_req_state_o_0==1 & (~load_resp_vld);

//      select RAW
wire [32-1:0]                           RAW_load_addr=lsu_ctrl_load?(lsu_op2_val+lsu_op1_val)  :0;
wire                                    RAW_load_type=(lsu_op2_val+lsu_op1_val)>32'h8000_0000 ? 1'b1:1'b0;  //1:mem 0:dev
wire [5:0]                  RAW_load_inst_id=lsu_ctrl_load?lsu_inst_id:0;
wire [16-1:0]               RAW_selector_in;
wire [$clog2(16)-1:0]       RAW_selector_out;
wire [$clog2(16)-1:0]       RAW_selector_out_cvs=16-1-RAW_selector_out;

idle_select_comp RAW_selector   ((~RAW_selector_in),RAW_selector_out);
assign RAW_flag =(RAW_selector_in !=0) && (RAW_load_type) && lsu_ctrl_load;

logic [$clog2(16)-1:0] tail_ptr,tail_ptr_nxt;
//      select flush
wire [16-1:0]               flush_selector_in ;
wire [16-1:0]               flush_selector_in_part ;  //
wire [16-1:0]               entry_flush_select;
assign entry_flush_select               =lsu_flush?flush_selector_in:0;
wire [$clog2(16)-1:0]       flush_selector_out;
wire [$clog2(16)-1:0]       flush_selector_out_part;
idle_select_comp flush_selector ((~flush_selector_in),flush_selector_out_part);
assign flush_selector_out =flush_selector_in[flush_selector_out_part]?flush_selector_out_part:tail_ptr;

    // print("assign RAW_selector_in[%d]     = (entry_req_addr_o_%d==RAW_load_addr) & (entry_req_id_o_%d<RAW_load_inst_id);"%(i,i,i))

wire   store_older_0                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_0 (entry_req_id_o_0,RAW_load_inst_id,store_older_0) ;
assign RAW_selected_0           = (entry_req_addr_o_0==RAW_load_addr) && (store_older_0) && (entry_req_state_o_0!=0);
assign RAW_selector_in[15]       = lsu_ctrl_load?(RAW_selected_0):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_0  (lsu_flush_id,entry_req_id_o_0,flush_selector_in_part[0]);
assign flush_selector_in[0]     = flush_selector_in_part[0] & (0<=tail_ptr)          ;
wire   store_older_1                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_1 (entry_req_id_o_1,RAW_load_inst_id,store_older_1) ;
assign RAW_selected_1           = (entry_req_addr_o_1==RAW_load_addr) && (store_older_1) && (entry_req_state_o_1!=0);
assign RAW_selector_in[14]       = lsu_ctrl_load?(RAW_selected_1):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_1  (lsu_flush_id,entry_req_id_o_1,flush_selector_in_part[1]);
assign flush_selector_in[1]     = flush_selector_in_part[1] & (1<=tail_ptr)          ;
wire   store_older_2                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_2 (entry_req_id_o_2,RAW_load_inst_id,store_older_2) ;
assign RAW_selected_2           = (entry_req_addr_o_2==RAW_load_addr) && (store_older_2) && (entry_req_state_o_2!=0);
assign RAW_selector_in[13]       = lsu_ctrl_load?(RAW_selected_2):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_2  (lsu_flush_id,entry_req_id_o_2,flush_selector_in_part[2]);
assign flush_selector_in[2]     = flush_selector_in_part[2] & (2<=tail_ptr)          ;
wire   store_older_3                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_3 (entry_req_id_o_3,RAW_load_inst_id,store_older_3) ;
assign RAW_selected_3           = (entry_req_addr_o_3==RAW_load_addr) && (store_older_3) && (entry_req_state_o_3!=0);
assign RAW_selector_in[12]       = lsu_ctrl_load?(RAW_selected_3):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_3  (lsu_flush_id,entry_req_id_o_3,flush_selector_in_part[3]);
assign flush_selector_in[3]     = flush_selector_in_part[3] & (3<=tail_ptr)          ;
wire   store_older_4                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_4 (entry_req_id_o_4,RAW_load_inst_id,store_older_4) ;
assign RAW_selected_4           = (entry_req_addr_o_4==RAW_load_addr) && (store_older_4) && (entry_req_state_o_4!=0);
assign RAW_selector_in[11]       = lsu_ctrl_load?(RAW_selected_4):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_4  (lsu_flush_id,entry_req_id_o_4,flush_selector_in_part[4]);
assign flush_selector_in[4]     = flush_selector_in_part[4] & (4<=tail_ptr)          ;
wire   store_older_5                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_5 (entry_req_id_o_5,RAW_load_inst_id,store_older_5) ;
assign RAW_selected_5           = (entry_req_addr_o_5==RAW_load_addr) && (store_older_5) && (entry_req_state_o_5!=0);
assign RAW_selector_in[10]       = lsu_ctrl_load?(RAW_selected_5):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_5  (lsu_flush_id,entry_req_id_o_5,flush_selector_in_part[5]);
assign flush_selector_in[5]     = flush_selector_in_part[5] & (5<=tail_ptr)          ;
wire   store_older_6                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_6 (entry_req_id_o_6,RAW_load_inst_id,store_older_6) ;
assign RAW_selected_6           = (entry_req_addr_o_6==RAW_load_addr) && (store_older_6) && (entry_req_state_o_6!=0);
assign RAW_selector_in[9]       = lsu_ctrl_load?(RAW_selected_6):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_6  (lsu_flush_id,entry_req_id_o_6,flush_selector_in_part[6]);
assign flush_selector_in[6]     = flush_selector_in_part[6] & (6<=tail_ptr)          ;
wire   store_older_7                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_7 (entry_req_id_o_7,RAW_load_inst_id,store_older_7) ;
assign RAW_selected_7           = (entry_req_addr_o_7==RAW_load_addr) && (store_older_7) && (entry_req_state_o_7!=0);
assign RAW_selector_in[8]       = lsu_ctrl_load?(RAW_selected_7):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_7  (lsu_flush_id,entry_req_id_o_7,flush_selector_in_part[7]);
assign flush_selector_in[7]     = flush_selector_in_part[7] & (7<=tail_ptr)          ;
wire   store_older_8                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_8 (entry_req_id_o_8,RAW_load_inst_id,store_older_8) ;
assign RAW_selected_8           = (entry_req_addr_o_8==RAW_load_addr) && (store_older_8) && (entry_req_state_o_8!=0);
assign RAW_selector_in[7]       = lsu_ctrl_load?(RAW_selected_8):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_8  (lsu_flush_id,entry_req_id_o_8,flush_selector_in_part[8]);
assign flush_selector_in[8]     = flush_selector_in_part[8] & (8<=tail_ptr)          ;
wire   store_older_9                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_9 (entry_req_id_o_9,RAW_load_inst_id,store_older_9) ;
assign RAW_selected_9           = (entry_req_addr_o_9==RAW_load_addr) && (store_older_9) && (entry_req_state_o_9!=0);
assign RAW_selector_in[6]       = lsu_ctrl_load?(RAW_selected_9):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_9  (lsu_flush_id,entry_req_id_o_9,flush_selector_in_part[9]);
assign flush_selector_in[9]     = flush_selector_in_part[9] & (9<=tail_ptr)          ;
wire   store_older_10                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_10 (entry_req_id_o_10,RAW_load_inst_id,store_older_10) ;
assign RAW_selected_10           = (entry_req_addr_o_10==RAW_load_addr) && (store_older_10) && (entry_req_state_o_10!=0);
assign RAW_selector_in[5]       = lsu_ctrl_load?(RAW_selected_10):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_10  (lsu_flush_id,entry_req_id_o_10,flush_selector_in_part[10]);
assign flush_selector_in[10]     = flush_selector_in_part[10] & (10<=tail_ptr)          ;
wire   store_older_11                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_11 (entry_req_id_o_11,RAW_load_inst_id,store_older_11) ;
assign RAW_selected_11           = (entry_req_addr_o_11==RAW_load_addr) && (store_older_11) && (entry_req_state_o_11!=0);
assign RAW_selector_in[4]       = lsu_ctrl_load?(RAW_selected_11):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_11  (lsu_flush_id,entry_req_id_o_11,flush_selector_in_part[11]);
assign flush_selector_in[11]     = flush_selector_in_part[11] & (11<=tail_ptr)          ;
wire   store_older_12                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_12 (entry_req_id_o_12,RAW_load_inst_id,store_older_12) ;
assign RAW_selected_12           = (entry_req_addr_o_12==RAW_load_addr) && (store_older_12) && (entry_req_state_o_12!=0);
assign RAW_selector_in[3]       = lsu_ctrl_load?(RAW_selected_12):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_12  (lsu_flush_id,entry_req_id_o_12,flush_selector_in_part[12]);
assign flush_selector_in[12]     = flush_selector_in_part[12] & (12<=tail_ptr)          ;
wire   store_older_13                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_13 (entry_req_id_o_13,RAW_load_inst_id,store_older_13) ;
assign RAW_selected_13           = (entry_req_addr_o_13==RAW_load_addr) && (store_older_13) && (entry_req_state_o_13!=0);
assign RAW_selector_in[2]       = lsu_ctrl_load?(RAW_selected_13):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_13  (lsu_flush_id,entry_req_id_o_13,flush_selector_in_part[13]);
assign flush_selector_in[13]     = flush_selector_in_part[13] & (13<=tail_ptr)          ;
wire   store_older_14                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_14 (entry_req_id_o_14,RAW_load_inst_id,store_older_14) ;
assign RAW_selected_14           = (entry_req_addr_o_14==RAW_load_addr) && (store_older_14) && (entry_req_state_o_14!=0);
assign RAW_selector_in[1]       = lsu_ctrl_load?(RAW_selected_14):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_14  (lsu_flush_id,entry_req_id_o_14,flush_selector_in_part[14]);
assign flush_selector_in[14]     = flush_selector_in_part[14] & (14<=tail_ptr)          ;
wire   store_older_15                                                                                ;
rob_id_cmpo #(.DW(5+1))  store_load_cmpo_15 (entry_req_id_o_15,RAW_load_inst_id,store_older_15) ;
assign RAW_selected_15           = (entry_req_addr_o_15==RAW_load_addr) && (store_older_15) && (entry_req_state_o_15!=0);
assign RAW_selector_in[0]       = lsu_ctrl_load?(RAW_selected_15):0 ;
rob_id_cmpo #(.DW(5+1)) ID_CMPO_15  (lsu_flush_id,entry_req_id_o_15,flush_selector_in_part[15]);
assign flush_selector_in[15]     = flush_selector_in_part[15] & (15<=tail_ptr)          ;
// print("assign flush_selector_in[%d]   = (entry_req_id_o_%d>lsu_flush_id) & (%d<=tail_ptr);"%(i,i,i));
//      select WAW
// wire [16-1:0]               entry_WAW_select                                                   ;
// wire [16-1:0]               entry_WAW_select_shift     = (entry_WAW_select & 2**(tail_ptr+1)-1)>>1  ;
// assign               store_WAW_selected        = rreq?entry_WAW_select_shift:entry_WAW_select;

// `psv_begin
// for i in range(0,16):
//     print("assign entry_WAW_select[%d] = entry_req_addr_o_%d==store_req_addr;"%(i,i));
// `psv_end

//              tail pointer
// logic [$clog2(16)-1:0] tail_ptr,tail_ptr_nxt;
wire                               queue_full      = tail_ptr ==16-1 ?1:0;
wire                               queue_empty     = tail_ptr ==0                ?1:0;
wire                               wreq            = store_req;
wire                               rreq            = (entry_req_state_o_0==0) & (tail_ptr>0); //head entry is empty
wire [2-1:0]                       req             ={rreq,wreq};
wire                               lsu_inst_id_older;
rob_id_cmpo #(.DW(5+1))  new_id_cmpo (lsu_inst_id,lsu_flush_id,lsu_inst_id_older);
wire                               pre_branch_flag = lsu_flush                   ?lsu_inst_id_older:1'b1;
wire [$clog2(16)-1:0]  flush_tail_nxt  = pre_branch_flag             ?flush_selector_out+1    :flush_selector_out;

always_comb begin
tail_ptr_nxt=tail_ptr;
        case (req)
            0:begin
                tail_ptr_nxt=lsu_flush ? flush_selector_out:tail_ptr;
            end
            1:begin
                tail_ptr_nxt=lsu_flush ? flush_tail_nxt:
                             queue_full? tail_ptr      :tail_ptr+1;
            end
            2:begin
                tail_ptr_nxt=lsu_flush  ? flush_selector_out-1:
                             queue_empty? tail_ptr            :tail_ptr-1;
            end
            3:begin
                tail_ptr_nxt=lsu_flush ? flush_selector_out:tail_ptr;
            end
        endcase
end
dffr #(.DW($clog2(16)))      tail_ptr_ff         (clk,rst_n,1'b1,tail_ptr_nxt,tail_ptr);

wire [$clog2(16)-1:0]   in_tail              =lsu_flush                   ? flush_selector_out :
                                                          rreq                        ? tail_ptr-1         : tail_ptr;
wire [16-1:0]           store_in_selected    =store_req & pre_branch_flag ? 2**in_tail         : 0       ;

// assign lsu_store_ready_in                                =;
// dffr #(1)                           lsu_store_ready_ff  (clk,rst_n,1'b1,lsu_store_ready_in,lsu_store_ready);
assign                              lsu_store_ready      =!queue_full;

//cache store req
assign  dmem_store_req      =store_cache_selected!=0;
assign  dmem_store_req_tid  =entry_req_id_o_0;
assign  dmem_store_addr     =entry_req_addr_o_0;
assign  dmem_store_wdata    =entry_store_data_o_0;
assign  dmem_store_info     =entry_req_info_o_0;
// assign  dmem_store_flush    =
//resp store
wire                        store_resp_flag_nxt=load_resp_vld == store_resp_vld;
wire                        store_resp_vld_flag;
dffr #(.DW(1))                  resp_vld_ff   (clk,rst_n,1'b1,store_resp_flag_nxt,store_resp_vld_flag);
assign      store_resp_inst_id  ={(5+1){store_resp_vld}} & entry_req_id_o_0;
// assign      store_resp_vld      =(entry_req_state_o_0 ==1) & store_resp_vld_flag;  // wait 
assign      store_resp_vld      =entry_req_state_o_0 ==10;  // wait 
assign      store_resp_rd_vld   =1'b0;
assign      store_resp_rd_ind   =0;
assign      store_resp_rd_val   =0;
assign      store_exp_vld       =0;


//ddr store
assign  ddr_store_req       =store_ddr_selected!=0;
assign  ddr_store_req_tid   =entry_req_id_o_0;
assign  ddr_store_addr      =entry_req_addr_o_0;
assign  ddr_store_wdata     =entry_store_data_o_0;
//dev store
assign  dev_store_req       =store_dev_selected!=0;
wire [31:0]  dev_store_addr      =entry_req_addr_o_0;
wire [31:0]  dev_store_wdata     =entry_store_data_o_0;
assign  dev_store_tid       =entry_req_id_o_0;
wire [2-1:0]                        store_req_width_type =lsu_ctrl_byte? 2:
                                                         lsu_ctrl_half? 1:
                                                         lsu_ctrl_word? 0:3;
wire [3-1:0]                        store_req_info       ={lsu_ctrl_unsign,store_req_width_type};
//entrys input

wire [31:0]               lsu_req_addr   =lsu_op2_val+lsu_op1_val;

wire [32-1:0]                entry_req_addr_0   =  store_in_selected[0]   ?lsu_req_addr           :entry_req_addr_o_1    ;
wire [5+1-1:0]   entry_req_id_0     =  store_in_selected[0]   ?lsu_inst_id            :entry_req_id_o_1      ;
wire [1-1:0]                 entry_vld_0        =  store_in_selected[0]   ?1'b1                   :entry_vld_o_1         ;
wire [4-1:0]                 entry_req_state_0  =  store_in_selected[0]   ?1                      :entry_req_state_o_1   ;
wire [1-1:0]                 entry_req_type_0   =  store_in_selected[0]   ?lsu_req_type           :entry_req_type_o_1    ;
wire [32-1:0]                entry_store_data_0 =  store_in_selected[0]   ?lsu_store_data             :entry_store_data_o_1  ;
wire                         entry_store_tag_0  =  store_WAW_selected[0]  ?1                      :entry_store_tag_o_1   ;
wire [3-1:0]                 entry_req_info_0   =  store_in_selected[0]   ?store_req_info         :entry_req_info_o_1    ;
wire [32-1:0]                entry_req_addr_1   =  store_in_selected[1]   ?lsu_req_addr           :entry_req_addr_o_2    ;
wire [5+1-1:0]   entry_req_id_1     =  store_in_selected[1]   ?lsu_inst_id            :entry_req_id_o_2      ;
wire [1-1:0]                 entry_vld_1        =  store_in_selected[1]   ?1'b1                   :entry_vld_o_2         ;
wire [4-1:0]                 entry_req_state_1  =  store_in_selected[1]   ?1                      :entry_req_state_o_2   ;
wire [1-1:0]                 entry_req_type_1   =  store_in_selected[1]   ?lsu_req_type           :entry_req_type_o_2    ;
wire [32-1:0]                entry_store_data_1 =  store_in_selected[1]   ?lsu_store_data             :entry_store_data_o_2  ;
wire                         entry_store_tag_1  =  store_WAW_selected[1]  ?1                      :entry_store_tag_o_2   ;
wire [3-1:0]                 entry_req_info_1   =  store_in_selected[1]   ?store_req_info         :entry_req_info_o_2    ;
wire [32-1:0]                entry_req_addr_2   =  store_in_selected[2]   ?lsu_req_addr           :entry_req_addr_o_3    ;
wire [5+1-1:0]   entry_req_id_2     =  store_in_selected[2]   ?lsu_inst_id            :entry_req_id_o_3      ;
wire [1-1:0]                 entry_vld_2        =  store_in_selected[2]   ?1'b1                   :entry_vld_o_3         ;
wire [4-1:0]                 entry_req_state_2  =  store_in_selected[2]   ?1                      :entry_req_state_o_3   ;
wire [1-1:0]                 entry_req_type_2   =  store_in_selected[2]   ?lsu_req_type           :entry_req_type_o_3    ;
wire [32-1:0]                entry_store_data_2 =  store_in_selected[2]   ?lsu_store_data             :entry_store_data_o_3  ;
wire                         entry_store_tag_2  =  store_WAW_selected[2]  ?1                      :entry_store_tag_o_3   ;
wire [3-1:0]                 entry_req_info_2   =  store_in_selected[2]   ?store_req_info         :entry_req_info_o_3    ;
wire [32-1:0]                entry_req_addr_3   =  store_in_selected[3]   ?lsu_req_addr           :entry_req_addr_o_4    ;
wire [5+1-1:0]   entry_req_id_3     =  store_in_selected[3]   ?lsu_inst_id            :entry_req_id_o_4      ;
wire [1-1:0]                 entry_vld_3        =  store_in_selected[3]   ?1'b1                   :entry_vld_o_4         ;
wire [4-1:0]                 entry_req_state_3  =  store_in_selected[3]   ?1                      :entry_req_state_o_4   ;
wire [1-1:0]                 entry_req_type_3   =  store_in_selected[3]   ?lsu_req_type           :entry_req_type_o_4    ;
wire [32-1:0]                entry_store_data_3 =  store_in_selected[3]   ?lsu_store_data             :entry_store_data_o_4  ;
wire                         entry_store_tag_3  =  store_WAW_selected[3]  ?1                      :entry_store_tag_o_4   ;
wire [3-1:0]                 entry_req_info_3   =  store_in_selected[3]   ?store_req_info         :entry_req_info_o_4    ;
wire [32-1:0]                entry_req_addr_4   =  store_in_selected[4]   ?lsu_req_addr           :entry_req_addr_o_5    ;
wire [5+1-1:0]   entry_req_id_4     =  store_in_selected[4]   ?lsu_inst_id            :entry_req_id_o_5      ;
wire [1-1:0]                 entry_vld_4        =  store_in_selected[4]   ?1'b1                   :entry_vld_o_5         ;
wire [4-1:0]                 entry_req_state_4  =  store_in_selected[4]   ?1                      :entry_req_state_o_5   ;
wire [1-1:0]                 entry_req_type_4   =  store_in_selected[4]   ?lsu_req_type           :entry_req_type_o_5    ;
wire [32-1:0]                entry_store_data_4 =  store_in_selected[4]   ?lsu_store_data             :entry_store_data_o_5  ;
wire                         entry_store_tag_4  =  store_WAW_selected[4]  ?1                      :entry_store_tag_o_5   ;
wire [3-1:0]                 entry_req_info_4   =  store_in_selected[4]   ?store_req_info         :entry_req_info_o_5    ;
wire [32-1:0]                entry_req_addr_5   =  store_in_selected[5]   ?lsu_req_addr           :entry_req_addr_o_6    ;
wire [5+1-1:0]   entry_req_id_5     =  store_in_selected[5]   ?lsu_inst_id            :entry_req_id_o_6      ;
wire [1-1:0]                 entry_vld_5        =  store_in_selected[5]   ?1'b1                   :entry_vld_o_6         ;
wire [4-1:0]                 entry_req_state_5  =  store_in_selected[5]   ?1                      :entry_req_state_o_6   ;
wire [1-1:0]                 entry_req_type_5   =  store_in_selected[5]   ?lsu_req_type           :entry_req_type_o_6    ;
wire [32-1:0]                entry_store_data_5 =  store_in_selected[5]   ?lsu_store_data             :entry_store_data_o_6  ;
wire                         entry_store_tag_5  =  store_WAW_selected[5]  ?1                      :entry_store_tag_o_6   ;
wire [3-1:0]                 entry_req_info_5   =  store_in_selected[5]   ?store_req_info         :entry_req_info_o_6    ;
wire [32-1:0]                entry_req_addr_6   =  store_in_selected[6]   ?lsu_req_addr           :entry_req_addr_o_7    ;
wire [5+1-1:0]   entry_req_id_6     =  store_in_selected[6]   ?lsu_inst_id            :entry_req_id_o_7      ;
wire [1-1:0]                 entry_vld_6        =  store_in_selected[6]   ?1'b1                   :entry_vld_o_7         ;
wire [4-1:0]                 entry_req_state_6  =  store_in_selected[6]   ?1                      :entry_req_state_o_7   ;
wire [1-1:0]                 entry_req_type_6   =  store_in_selected[6]   ?lsu_req_type           :entry_req_type_o_7    ;
wire [32-1:0]                entry_store_data_6 =  store_in_selected[6]   ?lsu_store_data             :entry_store_data_o_7  ;
wire                         entry_store_tag_6  =  store_WAW_selected[6]  ?1                      :entry_store_tag_o_7   ;
wire [3-1:0]                 entry_req_info_6   =  store_in_selected[6]   ?store_req_info         :entry_req_info_o_7    ;
wire [32-1:0]                entry_req_addr_7   =  store_in_selected[7]   ?lsu_req_addr           :entry_req_addr_o_8    ;
wire [5+1-1:0]   entry_req_id_7     =  store_in_selected[7]   ?lsu_inst_id            :entry_req_id_o_8      ;
wire [1-1:0]                 entry_vld_7        =  store_in_selected[7]   ?1'b1                   :entry_vld_o_8         ;
wire [4-1:0]                 entry_req_state_7  =  store_in_selected[7]   ?1                      :entry_req_state_o_8   ;
wire [1-1:0]                 entry_req_type_7   =  store_in_selected[7]   ?lsu_req_type           :entry_req_type_o_8    ;
wire [32-1:0]                entry_store_data_7 =  store_in_selected[7]   ?lsu_store_data             :entry_store_data_o_8  ;
wire                         entry_store_tag_7  =  store_WAW_selected[7]  ?1                      :entry_store_tag_o_8   ;
wire [3-1:0]                 entry_req_info_7   =  store_in_selected[7]   ?store_req_info         :entry_req_info_o_8    ;
wire [32-1:0]                entry_req_addr_8   =  store_in_selected[8]   ?lsu_req_addr           :entry_req_addr_o_9    ;
wire [5+1-1:0]   entry_req_id_8     =  store_in_selected[8]   ?lsu_inst_id            :entry_req_id_o_9      ;
wire [1-1:0]                 entry_vld_8        =  store_in_selected[8]   ?1'b1                   :entry_vld_o_9         ;
wire [4-1:0]                 entry_req_state_8  =  store_in_selected[8]   ?1                      :entry_req_state_o_9   ;
wire [1-1:0]                 entry_req_type_8   =  store_in_selected[8]   ?lsu_req_type           :entry_req_type_o_9    ;
wire [32-1:0]                entry_store_data_8 =  store_in_selected[8]   ?lsu_store_data             :entry_store_data_o_9  ;
wire                         entry_store_tag_8  =  store_WAW_selected[8]  ?1                      :entry_store_tag_o_9   ;
wire [3-1:0]                 entry_req_info_8   =  store_in_selected[8]   ?store_req_info         :entry_req_info_o_9    ;
wire [32-1:0]                entry_req_addr_9   =  store_in_selected[9]   ?lsu_req_addr           :entry_req_addr_o_10    ;
wire [5+1-1:0]   entry_req_id_9     =  store_in_selected[9]   ?lsu_inst_id            :entry_req_id_o_10      ;
wire [1-1:0]                 entry_vld_9        =  store_in_selected[9]   ?1'b1                   :entry_vld_o_10         ;
wire [4-1:0]                 entry_req_state_9  =  store_in_selected[9]   ?1                      :entry_req_state_o_10   ;
wire [1-1:0]                 entry_req_type_9   =  store_in_selected[9]   ?lsu_req_type           :entry_req_type_o_10    ;
wire [32-1:0]                entry_store_data_9 =  store_in_selected[9]   ?lsu_store_data             :entry_store_data_o_10  ;
wire                         entry_store_tag_9  =  store_WAW_selected[9]  ?1                      :entry_store_tag_o_10   ;
wire [3-1:0]                 entry_req_info_9   =  store_in_selected[9]   ?store_req_info         :entry_req_info_o_10    ;
wire [32-1:0]                entry_req_addr_10   =  store_in_selected[10]   ?lsu_req_addr           :entry_req_addr_o_11    ;
wire [5+1-1:0]   entry_req_id_10     =  store_in_selected[10]   ?lsu_inst_id            :entry_req_id_o_11      ;
wire [1-1:0]                 entry_vld_10        =  store_in_selected[10]   ?1'b1                   :entry_vld_o_11         ;
wire [4-1:0]                 entry_req_state_10  =  store_in_selected[10]   ?1                      :entry_req_state_o_11   ;
wire [1-1:0]                 entry_req_type_10   =  store_in_selected[10]   ?lsu_req_type           :entry_req_type_o_11    ;
wire [32-1:0]                entry_store_data_10 =  store_in_selected[10]   ?lsu_store_data             :entry_store_data_o_11  ;
wire                         entry_store_tag_10  =  store_WAW_selected[10]  ?1                      :entry_store_tag_o_11   ;
wire [3-1:0]                 entry_req_info_10   =  store_in_selected[10]   ?store_req_info         :entry_req_info_o_11    ;
wire [32-1:0]                entry_req_addr_11   =  store_in_selected[11]   ?lsu_req_addr           :entry_req_addr_o_12    ;
wire [5+1-1:0]   entry_req_id_11     =  store_in_selected[11]   ?lsu_inst_id            :entry_req_id_o_12      ;
wire [1-1:0]                 entry_vld_11        =  store_in_selected[11]   ?1'b1                   :entry_vld_o_12         ;
wire [4-1:0]                 entry_req_state_11  =  store_in_selected[11]   ?1                      :entry_req_state_o_12   ;
wire [1-1:0]                 entry_req_type_11   =  store_in_selected[11]   ?lsu_req_type           :entry_req_type_o_12    ;
wire [32-1:0]                entry_store_data_11 =  store_in_selected[11]   ?lsu_store_data             :entry_store_data_o_12  ;
wire                         entry_store_tag_11  =  store_WAW_selected[11]  ?1                      :entry_store_tag_o_12   ;
wire [3-1:0]                 entry_req_info_11   =  store_in_selected[11]   ?store_req_info         :entry_req_info_o_12    ;
wire [32-1:0]                entry_req_addr_12   =  store_in_selected[12]   ?lsu_req_addr           :entry_req_addr_o_13    ;
wire [5+1-1:0]   entry_req_id_12     =  store_in_selected[12]   ?lsu_inst_id            :entry_req_id_o_13      ;
wire [1-1:0]                 entry_vld_12        =  store_in_selected[12]   ?1'b1                   :entry_vld_o_13         ;
wire [4-1:0]                 entry_req_state_12  =  store_in_selected[12]   ?1                      :entry_req_state_o_13   ;
wire [1-1:0]                 entry_req_type_12   =  store_in_selected[12]   ?lsu_req_type           :entry_req_type_o_13    ;
wire [32-1:0]                entry_store_data_12 =  store_in_selected[12]   ?lsu_store_data             :entry_store_data_o_13  ;
wire                         entry_store_tag_12  =  store_WAW_selected[12]  ?1                      :entry_store_tag_o_13   ;
wire [3-1:0]                 entry_req_info_12   =  store_in_selected[12]   ?store_req_info         :entry_req_info_o_13    ;
wire [32-1:0]                entry_req_addr_13   =  store_in_selected[13]   ?lsu_req_addr           :entry_req_addr_o_14    ;
wire [5+1-1:0]   entry_req_id_13     =  store_in_selected[13]   ?lsu_inst_id            :entry_req_id_o_14      ;
wire [1-1:0]                 entry_vld_13        =  store_in_selected[13]   ?1'b1                   :entry_vld_o_14         ;
wire [4-1:0]                 entry_req_state_13  =  store_in_selected[13]   ?1                      :entry_req_state_o_14   ;
wire [1-1:0]                 entry_req_type_13   =  store_in_selected[13]   ?lsu_req_type           :entry_req_type_o_14    ;
wire [32-1:0]                entry_store_data_13 =  store_in_selected[13]   ?lsu_store_data             :entry_store_data_o_14  ;
wire                         entry_store_tag_13  =  store_WAW_selected[13]  ?1                      :entry_store_tag_o_14   ;
wire [3-1:0]                 entry_req_info_13   =  store_in_selected[13]   ?store_req_info         :entry_req_info_o_14    ;
wire [32-1:0]                entry_req_addr_14   =  store_in_selected[14]   ?lsu_req_addr           :entry_req_addr_o_15    ;
wire [5+1-1:0]   entry_req_id_14     =  store_in_selected[14]   ?lsu_inst_id            :entry_req_id_o_15      ;
wire [1-1:0]                 entry_vld_14        =  store_in_selected[14]   ?1'b1                   :entry_vld_o_15         ;
wire [4-1:0]                 entry_req_state_14  =  store_in_selected[14]   ?1                      :entry_req_state_o_15   ;
wire [1-1:0]                 entry_req_type_14   =  store_in_selected[14]   ?lsu_req_type           :entry_req_type_o_15    ;
wire [32-1:0]                entry_store_data_14 =  store_in_selected[14]   ?lsu_store_data             :entry_store_data_o_15  ;
wire                         entry_store_tag_14  =  store_WAW_selected[14]  ?1                      :entry_store_tag_o_15   ;
wire [3-1:0]                 entry_req_info_14   =  store_in_selected[14]   ?store_req_info         :entry_req_info_o_15    ;
wire [32-1:0]                           entry_req_addr_15   =  store_in_selected[15]    ?  lsu_req_addr           :0 ;
wire [5+1-1:0]              entry_req_id_15     =  store_in_selected[15]    ?  lsu_inst_id            :0 ;
wire [1-1:0]                            entry_vld_15        =  store_in_selected[15]    ?  1'b1                   :0 ;
wire [4-1:0]                            entry_req_state_15  =  store_in_selected[15]    ?  0                      :0 ;
wire [1-1:0]                            entry_req_type_15   =  store_in_selected[15]    ?  lsu_req_type           :0 ;
wire [32-1:0]                           entry_store_data_15 =  store_in_selected[15]    ?  lsu_store_data             :0 ;
wire [1-1:0]                            entry_store_tag_15  =  store_WAW_selected[15]   ?  1                      :0 ;
wire [3-1:0]                            entry_req_info_15   =  store_in_selected[15]    ?  store_req_info         :0 ;




// wire [$clog2(16)-1:0]       flush_tail           =pre_branch_flag ? flush_selector_out:0       ;
// wire [$clog2(16)-1:0]       in_tail              =lsu_flush       ? flush_tail        :tail_ptr;
// wire [16-1:0]               req_sel_value        =pre_branch_flag ? 2**in_tail        :0       ;
// wire [16-1:0]               store_in_selected    =store_req       ? req_sel_value     :0       ;

wire [31:0]               RAW_store_data;
wire [31:0]               RAW_store_addr;
wire [3-1:0]              RAW_store_info;

wire [31:0]               mem_wdata_byte;
wire [31:0]               mem_wdata_half;
wire [31:0]               mem_wdata_word;
wire [31:0]               store_data;
assign                    mem_wdata_byte = {32{RAW_store_addr[1:0] == 2'b00}} & {24'b0,RAW_store_data[7:0]} |
                                           {32{RAW_store_addr[1:0] == 2'b01}} & {16'b0,RAW_store_data[7:0],8'b0} |
                                           {32{RAW_store_addr[1:0] == 2'b10}} & {8'b0,RAW_store_data[7:0],16'b0} |
                                           {32{RAW_store_addr[1:0] == 2'b11}} & {RAW_store_data[7:0],24'b0} ;
assign                    mem_wdata_half = {32{RAW_store_addr[1:0] == 2'b00}} & {16'b0,RAW_store_data[15:0]} |
                                           {32{RAW_store_addr[1:0] == 2'b10}} & {RAW_store_data[15:0],16'b0} ;
assign                    mem_wdata_word = RAW_store_data;
assign                    RAW_load_data  = {32{RAW_store_info[1:0]==2}} & mem_wdata_byte |
                                           {32{RAW_store_info[1:0]==1}} & mem_wdata_half |
                                           {32{RAW_store_info[1:0]==0}} & mem_wdata_word ;

assign RAW_store_data =
({32{RAW_selector_out_cvs==0}} & entry_store_data_o_0 )|
({32{RAW_selector_out_cvs==1}} & entry_store_data_o_1 )|
({32{RAW_selector_out_cvs==2}} & entry_store_data_o_2 )|
({32{RAW_selector_out_cvs==3}} & entry_store_data_o_3 )|
({32{RAW_selector_out_cvs==4}} & entry_store_data_o_4 )|
({32{RAW_selector_out_cvs==5}} & entry_store_data_o_5 )|
({32{RAW_selector_out_cvs==6}} & entry_store_data_o_6 )|
({32{RAW_selector_out_cvs==7}} & entry_store_data_o_7 )|
({32{RAW_selector_out_cvs==8}} & entry_store_data_o_8 )|
({32{RAW_selector_out_cvs==9}} & entry_store_data_o_9 )|
({32{RAW_selector_out_cvs==10}} & entry_store_data_o_10 )|
({32{RAW_selector_out_cvs==11}} & entry_store_data_o_11 )|
({32{RAW_selector_out_cvs==12}} & entry_store_data_o_12 )|
({32{RAW_selector_out_cvs==13}} & entry_store_data_o_13 )|
({32{RAW_selector_out_cvs==14}} & entry_store_data_o_14 )|
({32{RAW_selector_out_cvs==15}} & entry_store_data_o_15);
assign RAW_store_addr =
({32{RAW_selector_out_cvs==0}} & entry_req_addr_o_0 )|
({32{RAW_selector_out_cvs==1}} & entry_req_addr_o_1 )|
({32{RAW_selector_out_cvs==2}} & entry_req_addr_o_2 )|
({32{RAW_selector_out_cvs==3}} & entry_req_addr_o_3 )|
({32{RAW_selector_out_cvs==4}} & entry_req_addr_o_4 )|
({32{RAW_selector_out_cvs==5}} & entry_req_addr_o_5 )|
({32{RAW_selector_out_cvs==6}} & entry_req_addr_o_6 )|
({32{RAW_selector_out_cvs==7}} & entry_req_addr_o_7 )|
({32{RAW_selector_out_cvs==8}} & entry_req_addr_o_8 )|
({32{RAW_selector_out_cvs==9}} & entry_req_addr_o_9 )|
({32{RAW_selector_out_cvs==10}} & entry_req_addr_o_10 )|
({32{RAW_selector_out_cvs==11}} & entry_req_addr_o_11 )|
({32{RAW_selector_out_cvs==12}} & entry_req_addr_o_12 )|
({32{RAW_selector_out_cvs==13}} & entry_req_addr_o_13 )|
({32{RAW_selector_out_cvs==14}} & entry_req_addr_o_14 )|
({32{RAW_selector_out_cvs==15}} & entry_req_addr_o_15);
assign RAW_store_info =
({3{RAW_selector_out_cvs==0}} & entry_req_info_o_0 )|
({3{RAW_selector_out_cvs==1}} & entry_req_info_o_1 )|
({3{RAW_selector_out_cvs==2}} & entry_req_info_o_2 )|
({3{RAW_selector_out_cvs==3}} & entry_req_info_o_3 )|
({3{RAW_selector_out_cvs==4}} & entry_req_info_o_4 )|
({3{RAW_selector_out_cvs==5}} & entry_req_info_o_5 )|
({3{RAW_selector_out_cvs==6}} & entry_req_info_o_6 )|
({3{RAW_selector_out_cvs==7}} & entry_req_info_o_7 )|
({3{RAW_selector_out_cvs==8}} & entry_req_info_o_8 )|
({3{RAW_selector_out_cvs==9}} & entry_req_info_o_9 )|
({3{RAW_selector_out_cvs==10}} & entry_req_info_o_10 )|
({3{RAW_selector_out_cvs==11}} & entry_req_info_o_11 )|
({3{RAW_selector_out_cvs==12}} & entry_req_info_o_12 )|
({3{RAW_selector_out_cvs==13}} & entry_req_info_o_13 )|
({3{RAW_selector_out_cvs==14}} & entry_req_info_o_14 )|
({3{RAW_selector_out_cvs==15}} & entry_req_info_o_15);

wire [3:0]      byte_strb;
wire [3:0]      half_strb;
wire [3:0]      word_strb;
assign                    byte_strb      = {4{dev_store_addr[1:0] == 2'b00}} & 4'b0001 |
                                           {4{dev_store_addr[1:0] == 2'b01}} & 4'b0010 |
                                           {4{dev_store_addr[1:0] == 2'b10}} & 4'b0100 |
                                           {4{dev_store_addr[1:0] == 2'b11}} & 4'b1000 ;
assign                    half_strb      = {4{dev_store_addr[1:0] == 2'b00}} & 4'b0011 |
                                           {4{dev_store_addr[1:0] == 2'b10}} & 4'b1100 ;
assign                    word_strb      = 4'b1111;                                     // to optimize : reuse strb in lsu top
assign                    store_strb      = {4{dmem_store_info[1:0]==2}} & byte_strb |        // byte
                                           {4{dmem_store_info[1:0]==1}} & half_strb |        // half
                                           {4{dmem_store_info[1:0]==0}} & word_strb ;        // word

//axi
assign                   dev_awaddr   =dev_store_addr;
assign                   dev_awprot   =0;
assign                   dev_awvalid  =dev_store_req |store_dev_wready;

assign                   dev_wdata    =dev_store_wdata;
assign                   dev_wvalid   =dev_store_req | store_dev_awready ;
assign                   dev_wstrb    =store_strb;

assign                   dev_bready   =entry_req_state_o_0==9;



frv_store_entry inst_frv_store_entry_0                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[0])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[0])    ,
     .cache_selected     (store_cache_selected[0])   ,
     .cache_miss         (store_cache_miss[0])       ,
     .cache_hit          (store_cache_hit[0])        ,
     .ddr_selected       (store_ddr_selected[0])     ,
     .ddr_ack            (store_ddr_ack[0])          ,
     .dev_selected       (store_dev_selected[0])     ,
     .selected_WAW       (store_WAW_selected[0])     ,
     .flush_selected     (entry_flush_select[0])     ,
     .resp_selected      (store_resp_selected[0])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[0])      ,
     .dev_store_wready   (dev_store_wready[0])       ,
     .dev_store_bvalid   (dev_store_bvalid[0])       ,
     .entry_req_addr      (entry_req_addr_0)          ,
     .entry_req_id        (entry_req_id_0)            ,
     .entry_vld           (entry_vld_0)               ,
     .entry_req_state     (entry_req_state_0)         ,
     .entry_req_type      (entry_req_type_0)          ,
     .entry_store_data    (entry_store_data_0)        ,
     .entry_store_tag     (entry_store_tag_0)         ,
     .entry_req_info      (entry_req_info_0)          ,
     .entry_req_addr_o   (entry_req_addr_o_0)        ,
     .entry_req_id_o     (entry_req_id_o_0)          ,
     .entry_vld_o        (entry_vld_o_0)             ,
     .entry_req_state_o  (entry_req_state_o_0)       ,
     .entry_req_type_o   (entry_req_type_o_0)        ,
     .entry_store_data_o (entry_store_data_o_0)      ,
     .entry_store_tag_o  (entry_store_tag_o_0)       ,
     .entry_req_info_o   (entry_req_info_o_0)         
 );
                                                  
frv_store_entry inst_frv_store_entry_1                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[1])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[1])    ,
     .cache_selected     (store_cache_selected[1])   ,
     .cache_miss         (store_cache_miss[1])       ,
     .cache_hit          (store_cache_hit[1])        ,
     .ddr_selected       (store_ddr_selected[1])     ,
     .ddr_ack            (store_ddr_ack[1])          ,
     .dev_selected       (store_dev_selected[1])     ,
     .selected_WAW       (store_WAW_selected[1])     ,
     .flush_selected     (entry_flush_select[1])     ,
     .resp_selected      (store_resp_selected[1])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[1])      ,
     .dev_store_wready   (dev_store_wready[1])       ,
     .dev_store_bvalid   (dev_store_bvalid[1])       ,
     .entry_req_addr      (entry_req_addr_1)          ,
     .entry_req_id        (entry_req_id_1)            ,
     .entry_vld           (entry_vld_1)               ,
     .entry_req_state     (entry_req_state_1)         ,
     .entry_req_type      (entry_req_type_1)          ,
     .entry_store_data    (entry_store_data_1)        ,
     .entry_store_tag     (entry_store_tag_1)         ,
     .entry_req_info      (entry_req_info_1)          ,
     .entry_req_addr_o   (entry_req_addr_o_1)        ,
     .entry_req_id_o     (entry_req_id_o_1)          ,
     .entry_vld_o        (entry_vld_o_1)             ,
     .entry_req_state_o  (entry_req_state_o_1)       ,
     .entry_req_type_o   (entry_req_type_o_1)        ,
     .entry_store_data_o (entry_store_data_o_1)      ,
     .entry_store_tag_o  (entry_store_tag_o_1)       ,
     .entry_req_info_o   (entry_req_info_o_1)         
 );
                                                  
frv_store_entry inst_frv_store_entry_2                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[2])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[2])    ,
     .cache_selected     (store_cache_selected[2])   ,
     .cache_miss         (store_cache_miss[2])       ,
     .cache_hit          (store_cache_hit[2])        ,
     .ddr_selected       (store_ddr_selected[2])     ,
     .ddr_ack            (store_ddr_ack[2])          ,
     .dev_selected       (store_dev_selected[2])     ,
     .selected_WAW       (store_WAW_selected[2])     ,
     .flush_selected     (entry_flush_select[2])     ,
     .resp_selected      (store_resp_selected[2])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[2])      ,
     .dev_store_wready   (dev_store_wready[2])       ,
     .dev_store_bvalid   (dev_store_bvalid[2])       ,
     .entry_req_addr      (entry_req_addr_2)          ,
     .entry_req_id        (entry_req_id_2)            ,
     .entry_vld           (entry_vld_2)               ,
     .entry_req_state     (entry_req_state_2)         ,
     .entry_req_type      (entry_req_type_2)          ,
     .entry_store_data    (entry_store_data_2)        ,
     .entry_store_tag     (entry_store_tag_2)         ,
     .entry_req_info      (entry_req_info_2)          ,
     .entry_req_addr_o   (entry_req_addr_o_2)        ,
     .entry_req_id_o     (entry_req_id_o_2)          ,
     .entry_vld_o        (entry_vld_o_2)             ,
     .entry_req_state_o  (entry_req_state_o_2)       ,
     .entry_req_type_o   (entry_req_type_o_2)        ,
     .entry_store_data_o (entry_store_data_o_2)      ,
     .entry_store_tag_o  (entry_store_tag_o_2)       ,
     .entry_req_info_o   (entry_req_info_o_2)         
 );
                                                  
frv_store_entry inst_frv_store_entry_3                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[3])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[3])    ,
     .cache_selected     (store_cache_selected[3])   ,
     .cache_miss         (store_cache_miss[3])       ,
     .cache_hit          (store_cache_hit[3])        ,
     .ddr_selected       (store_ddr_selected[3])     ,
     .ddr_ack            (store_ddr_ack[3])          ,
     .dev_selected       (store_dev_selected[3])     ,
     .selected_WAW       (store_WAW_selected[3])     ,
     .flush_selected     (entry_flush_select[3])     ,
     .resp_selected      (store_resp_selected[3])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[3])      ,
     .dev_store_wready   (dev_store_wready[3])       ,
     .dev_store_bvalid   (dev_store_bvalid[3])       ,
     .entry_req_addr      (entry_req_addr_3)          ,
     .entry_req_id        (entry_req_id_3)            ,
     .entry_vld           (entry_vld_3)               ,
     .entry_req_state     (entry_req_state_3)         ,
     .entry_req_type      (entry_req_type_3)          ,
     .entry_store_data    (entry_store_data_3)        ,
     .entry_store_tag     (entry_store_tag_3)         ,
     .entry_req_info      (entry_req_info_3)          ,
     .entry_req_addr_o   (entry_req_addr_o_3)        ,
     .entry_req_id_o     (entry_req_id_o_3)          ,
     .entry_vld_o        (entry_vld_o_3)             ,
     .entry_req_state_o  (entry_req_state_o_3)       ,
     .entry_req_type_o   (entry_req_type_o_3)        ,
     .entry_store_data_o (entry_store_data_o_3)      ,
     .entry_store_tag_o  (entry_store_tag_o_3)       ,
     .entry_req_info_o   (entry_req_info_o_3)         
 );
                                                  
frv_store_entry inst_frv_store_entry_4                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[4])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[4])    ,
     .cache_selected     (store_cache_selected[4])   ,
     .cache_miss         (store_cache_miss[4])       ,
     .cache_hit          (store_cache_hit[4])        ,
     .ddr_selected       (store_ddr_selected[4])     ,
     .ddr_ack            (store_ddr_ack[4])          ,
     .dev_selected       (store_dev_selected[4])     ,
     .selected_WAW       (store_WAW_selected[4])     ,
     .flush_selected     (entry_flush_select[4])     ,
     .resp_selected      (store_resp_selected[4])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[4])      ,
     .dev_store_wready   (dev_store_wready[4])       ,
     .dev_store_bvalid   (dev_store_bvalid[4])       ,
     .entry_req_addr      (entry_req_addr_4)          ,
     .entry_req_id        (entry_req_id_4)            ,
     .entry_vld           (entry_vld_4)               ,
     .entry_req_state     (entry_req_state_4)         ,
     .entry_req_type      (entry_req_type_4)          ,
     .entry_store_data    (entry_store_data_4)        ,
     .entry_store_tag     (entry_store_tag_4)         ,
     .entry_req_info      (entry_req_info_4)          ,
     .entry_req_addr_o   (entry_req_addr_o_4)        ,
     .entry_req_id_o     (entry_req_id_o_4)          ,
     .entry_vld_o        (entry_vld_o_4)             ,
     .entry_req_state_o  (entry_req_state_o_4)       ,
     .entry_req_type_o   (entry_req_type_o_4)        ,
     .entry_store_data_o (entry_store_data_o_4)      ,
     .entry_store_tag_o  (entry_store_tag_o_4)       ,
     .entry_req_info_o   (entry_req_info_o_4)         
 );
                                                  
frv_store_entry inst_frv_store_entry_5                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[5])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[5])    ,
     .cache_selected     (store_cache_selected[5])   ,
     .cache_miss         (store_cache_miss[5])       ,
     .cache_hit          (store_cache_hit[5])        ,
     .ddr_selected       (store_ddr_selected[5])     ,
     .ddr_ack            (store_ddr_ack[5])          ,
     .dev_selected       (store_dev_selected[5])     ,
     .selected_WAW       (store_WAW_selected[5])     ,
     .flush_selected     (entry_flush_select[5])     ,
     .resp_selected      (store_resp_selected[5])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[5])      ,
     .dev_store_wready   (dev_store_wready[5])       ,
     .dev_store_bvalid   (dev_store_bvalid[5])       ,
     .entry_req_addr      (entry_req_addr_5)          ,
     .entry_req_id        (entry_req_id_5)            ,
     .entry_vld           (entry_vld_5)               ,
     .entry_req_state     (entry_req_state_5)         ,
     .entry_req_type      (entry_req_type_5)          ,
     .entry_store_data    (entry_store_data_5)        ,
     .entry_store_tag     (entry_store_tag_5)         ,
     .entry_req_info      (entry_req_info_5)          ,
     .entry_req_addr_o   (entry_req_addr_o_5)        ,
     .entry_req_id_o     (entry_req_id_o_5)          ,
     .entry_vld_o        (entry_vld_o_5)             ,
     .entry_req_state_o  (entry_req_state_o_5)       ,
     .entry_req_type_o   (entry_req_type_o_5)        ,
     .entry_store_data_o (entry_store_data_o_5)      ,
     .entry_store_tag_o  (entry_store_tag_o_5)       ,
     .entry_req_info_o   (entry_req_info_o_5)         
 );
                                                  
frv_store_entry inst_frv_store_entry_6                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[6])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[6])    ,
     .cache_selected     (store_cache_selected[6])   ,
     .cache_miss         (store_cache_miss[6])       ,
     .cache_hit          (store_cache_hit[6])        ,
     .ddr_selected       (store_ddr_selected[6])     ,
     .ddr_ack            (store_ddr_ack[6])          ,
     .dev_selected       (store_dev_selected[6])     ,
     .selected_WAW       (store_WAW_selected[6])     ,
     .flush_selected     (entry_flush_select[6])     ,
     .resp_selected      (store_resp_selected[6])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[6])      ,
     .dev_store_wready   (dev_store_wready[6])       ,
     .dev_store_bvalid   (dev_store_bvalid[6])       ,
     .entry_req_addr      (entry_req_addr_6)          ,
     .entry_req_id        (entry_req_id_6)            ,
     .entry_vld           (entry_vld_6)               ,
     .entry_req_state     (entry_req_state_6)         ,
     .entry_req_type      (entry_req_type_6)          ,
     .entry_store_data    (entry_store_data_6)        ,
     .entry_store_tag     (entry_store_tag_6)         ,
     .entry_req_info      (entry_req_info_6)          ,
     .entry_req_addr_o   (entry_req_addr_o_6)        ,
     .entry_req_id_o     (entry_req_id_o_6)          ,
     .entry_vld_o        (entry_vld_o_6)             ,
     .entry_req_state_o  (entry_req_state_o_6)       ,
     .entry_req_type_o   (entry_req_type_o_6)        ,
     .entry_store_data_o (entry_store_data_o_6)      ,
     .entry_store_tag_o  (entry_store_tag_o_6)       ,
     .entry_req_info_o   (entry_req_info_o_6)         
 );
                                                  
frv_store_entry inst_frv_store_entry_7                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[7])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[7])    ,
     .cache_selected     (store_cache_selected[7])   ,
     .cache_miss         (store_cache_miss[7])       ,
     .cache_hit          (store_cache_hit[7])        ,
     .ddr_selected       (store_ddr_selected[7])     ,
     .ddr_ack            (store_ddr_ack[7])          ,
     .dev_selected       (store_dev_selected[7])     ,
     .selected_WAW       (store_WAW_selected[7])     ,
     .flush_selected     (entry_flush_select[7])     ,
     .resp_selected      (store_resp_selected[7])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[7])      ,
     .dev_store_wready   (dev_store_wready[7])       ,
     .dev_store_bvalid   (dev_store_bvalid[7])       ,
     .entry_req_addr      (entry_req_addr_7)          ,
     .entry_req_id        (entry_req_id_7)            ,
     .entry_vld           (entry_vld_7)               ,
     .entry_req_state     (entry_req_state_7)         ,
     .entry_req_type      (entry_req_type_7)          ,
     .entry_store_data    (entry_store_data_7)        ,
     .entry_store_tag     (entry_store_tag_7)         ,
     .entry_req_info      (entry_req_info_7)          ,
     .entry_req_addr_o   (entry_req_addr_o_7)        ,
     .entry_req_id_o     (entry_req_id_o_7)          ,
     .entry_vld_o        (entry_vld_o_7)             ,
     .entry_req_state_o  (entry_req_state_o_7)       ,
     .entry_req_type_o   (entry_req_type_o_7)        ,
     .entry_store_data_o (entry_store_data_o_7)      ,
     .entry_store_tag_o  (entry_store_tag_o_7)       ,
     .entry_req_info_o   (entry_req_info_o_7)         
 );
                                                  
frv_store_entry inst_frv_store_entry_8                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[8])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[8])    ,
     .cache_selected     (store_cache_selected[8])   ,
     .cache_miss         (store_cache_miss[8])       ,
     .cache_hit          (store_cache_hit[8])        ,
     .ddr_selected       (store_ddr_selected[8])     ,
     .ddr_ack            (store_ddr_ack[8])          ,
     .dev_selected       (store_dev_selected[8])     ,
     .selected_WAW       (store_WAW_selected[8])     ,
     .flush_selected     (entry_flush_select[8])     ,
     .resp_selected      (store_resp_selected[8])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[8])      ,
     .dev_store_wready   (dev_store_wready[8])       ,
     .dev_store_bvalid   (dev_store_bvalid[8])       ,
     .entry_req_addr      (entry_req_addr_8)          ,
     .entry_req_id        (entry_req_id_8)            ,
     .entry_vld           (entry_vld_8)               ,
     .entry_req_state     (entry_req_state_8)         ,
     .entry_req_type      (entry_req_type_8)          ,
     .entry_store_data    (entry_store_data_8)        ,
     .entry_store_tag     (entry_store_tag_8)         ,
     .entry_req_info      (entry_req_info_8)          ,
     .entry_req_addr_o   (entry_req_addr_o_8)        ,
     .entry_req_id_o     (entry_req_id_o_8)          ,
     .entry_vld_o        (entry_vld_o_8)             ,
     .entry_req_state_o  (entry_req_state_o_8)       ,
     .entry_req_type_o   (entry_req_type_o_8)        ,
     .entry_store_data_o (entry_store_data_o_8)      ,
     .entry_store_tag_o  (entry_store_tag_o_8)       ,
     .entry_req_info_o   (entry_req_info_o_8)         
 );
                                                  
frv_store_entry inst_frv_store_entry_9                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[9])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[9])    ,
     .cache_selected     (store_cache_selected[9])   ,
     .cache_miss         (store_cache_miss[9])       ,
     .cache_hit          (store_cache_hit[9])        ,
     .ddr_selected       (store_ddr_selected[9])     ,
     .ddr_ack            (store_ddr_ack[9])          ,
     .dev_selected       (store_dev_selected[9])     ,
     .selected_WAW       (store_WAW_selected[9])     ,
     .flush_selected     (entry_flush_select[9])     ,
     .resp_selected      (store_resp_selected[9])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[9])      ,
     .dev_store_wready   (dev_store_wready[9])       ,
     .dev_store_bvalid   (dev_store_bvalid[9])       ,
     .entry_req_addr      (entry_req_addr_9)          ,
     .entry_req_id        (entry_req_id_9)            ,
     .entry_vld           (entry_vld_9)               ,
     .entry_req_state     (entry_req_state_9)         ,
     .entry_req_type      (entry_req_type_9)          ,
     .entry_store_data    (entry_store_data_9)        ,
     .entry_store_tag     (entry_store_tag_9)         ,
     .entry_req_info      (entry_req_info_9)          ,
     .entry_req_addr_o   (entry_req_addr_o_9)        ,
     .entry_req_id_o     (entry_req_id_o_9)          ,
     .entry_vld_o        (entry_vld_o_9)             ,
     .entry_req_state_o  (entry_req_state_o_9)       ,
     .entry_req_type_o   (entry_req_type_o_9)        ,
     .entry_store_data_o (entry_store_data_o_9)      ,
     .entry_store_tag_o  (entry_store_tag_o_9)       ,
     .entry_req_info_o   (entry_req_info_o_9)         
 );
                                                  
frv_store_entry inst_frv_store_entry_10                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[10])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[10])    ,
     .cache_selected     (store_cache_selected[10])   ,
     .cache_miss         (store_cache_miss[10])       ,
     .cache_hit          (store_cache_hit[10])        ,
     .ddr_selected       (store_ddr_selected[10])     ,
     .ddr_ack            (store_ddr_ack[10])          ,
     .dev_selected       (store_dev_selected[10])     ,
     .selected_WAW       (store_WAW_selected[10])     ,
     .flush_selected     (entry_flush_select[10])     ,
     .resp_selected      (store_resp_selected[10])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[10])      ,
     .dev_store_wready   (dev_store_wready[10])       ,
     .dev_store_bvalid   (dev_store_bvalid[10])       ,
     .entry_req_addr      (entry_req_addr_10)          ,
     .entry_req_id        (entry_req_id_10)            ,
     .entry_vld           (entry_vld_10)               ,
     .entry_req_state     (entry_req_state_10)         ,
     .entry_req_type      (entry_req_type_10)          ,
     .entry_store_data    (entry_store_data_10)        ,
     .entry_store_tag     (entry_store_tag_10)         ,
     .entry_req_info      (entry_req_info_10)          ,
     .entry_req_addr_o   (entry_req_addr_o_10)        ,
     .entry_req_id_o     (entry_req_id_o_10)          ,
     .entry_vld_o        (entry_vld_o_10)             ,
     .entry_req_state_o  (entry_req_state_o_10)       ,
     .entry_req_type_o   (entry_req_type_o_10)        ,
     .entry_store_data_o (entry_store_data_o_10)      ,
     .entry_store_tag_o  (entry_store_tag_o_10)       ,
     .entry_req_info_o   (entry_req_info_o_10)         
 );
                                                  
frv_store_entry inst_frv_store_entry_11                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[11])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[11])    ,
     .cache_selected     (store_cache_selected[11])   ,
     .cache_miss         (store_cache_miss[11])       ,
     .cache_hit          (store_cache_hit[11])        ,
     .ddr_selected       (store_ddr_selected[11])     ,
     .ddr_ack            (store_ddr_ack[11])          ,
     .dev_selected       (store_dev_selected[11])     ,
     .selected_WAW       (store_WAW_selected[11])     ,
     .flush_selected     (entry_flush_select[11])     ,
     .resp_selected      (store_resp_selected[11])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[11])      ,
     .dev_store_wready   (dev_store_wready[11])       ,
     .dev_store_bvalid   (dev_store_bvalid[11])       ,
     .entry_req_addr      (entry_req_addr_11)          ,
     .entry_req_id        (entry_req_id_11)            ,
     .entry_vld           (entry_vld_11)               ,
     .entry_req_state     (entry_req_state_11)         ,
     .entry_req_type      (entry_req_type_11)          ,
     .entry_store_data    (entry_store_data_11)        ,
     .entry_store_tag     (entry_store_tag_11)         ,
     .entry_req_info      (entry_req_info_11)          ,
     .entry_req_addr_o   (entry_req_addr_o_11)        ,
     .entry_req_id_o     (entry_req_id_o_11)          ,
     .entry_vld_o        (entry_vld_o_11)             ,
     .entry_req_state_o  (entry_req_state_o_11)       ,
     .entry_req_type_o   (entry_req_type_o_11)        ,
     .entry_store_data_o (entry_store_data_o_11)      ,
     .entry_store_tag_o  (entry_store_tag_o_11)       ,
     .entry_req_info_o   (entry_req_info_o_11)         
 );
                                                  
frv_store_entry inst_frv_store_entry_12                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[12])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[12])    ,
     .cache_selected     (store_cache_selected[12])   ,
     .cache_miss         (store_cache_miss[12])       ,
     .cache_hit          (store_cache_hit[12])        ,
     .ddr_selected       (store_ddr_selected[12])     ,
     .ddr_ack            (store_ddr_ack[12])          ,
     .dev_selected       (store_dev_selected[12])     ,
     .selected_WAW       (store_WAW_selected[12])     ,
     .flush_selected     (entry_flush_select[12])     ,
     .resp_selected      (store_resp_selected[12])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[12])      ,
     .dev_store_wready   (dev_store_wready[12])       ,
     .dev_store_bvalid   (dev_store_bvalid[12])       ,
     .entry_req_addr      (entry_req_addr_12)          ,
     .entry_req_id        (entry_req_id_12)            ,
     .entry_vld           (entry_vld_12)               ,
     .entry_req_state     (entry_req_state_12)         ,
     .entry_req_type      (entry_req_type_12)          ,
     .entry_store_data    (entry_store_data_12)        ,
     .entry_store_tag     (entry_store_tag_12)         ,
     .entry_req_info      (entry_req_info_12)          ,
     .entry_req_addr_o   (entry_req_addr_o_12)        ,
     .entry_req_id_o     (entry_req_id_o_12)          ,
     .entry_vld_o        (entry_vld_o_12)             ,
     .entry_req_state_o  (entry_req_state_o_12)       ,
     .entry_req_type_o   (entry_req_type_o_12)        ,
     .entry_store_data_o (entry_store_data_o_12)      ,
     .entry_store_tag_o  (entry_store_tag_o_12)       ,
     .entry_req_info_o   (entry_req_info_o_12)         
 );
                                                  
frv_store_entry inst_frv_store_entry_13                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[13])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[13])    ,
     .cache_selected     (store_cache_selected[13])   ,
     .cache_miss         (store_cache_miss[13])       ,
     .cache_hit          (store_cache_hit[13])        ,
     .ddr_selected       (store_ddr_selected[13])     ,
     .ddr_ack            (store_ddr_ack[13])          ,
     .dev_selected       (store_dev_selected[13])     ,
     .selected_WAW       (store_WAW_selected[13])     ,
     .flush_selected     (entry_flush_select[13])     ,
     .resp_selected      (store_resp_selected[13])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[13])      ,
     .dev_store_wready   (dev_store_wready[13])       ,
     .dev_store_bvalid   (dev_store_bvalid[13])       ,
     .entry_req_addr      (entry_req_addr_13)          ,
     .entry_req_id        (entry_req_id_13)            ,
     .entry_vld           (entry_vld_13)               ,
     .entry_req_state     (entry_req_state_13)         ,
     .entry_req_type      (entry_req_type_13)          ,
     .entry_store_data    (entry_store_data_13)        ,
     .entry_store_tag     (entry_store_tag_13)         ,
     .entry_req_info      (entry_req_info_13)          ,
     .entry_req_addr_o   (entry_req_addr_o_13)        ,
     .entry_req_id_o     (entry_req_id_o_13)          ,
     .entry_vld_o        (entry_vld_o_13)             ,
     .entry_req_state_o  (entry_req_state_o_13)       ,
     .entry_req_type_o   (entry_req_type_o_13)        ,
     .entry_store_data_o (entry_store_data_o_13)      ,
     .entry_store_tag_o  (entry_store_tag_o_13)       ,
     .entry_req_info_o   (entry_req_info_o_13)         
 );
                                                  
frv_store_entry inst_frv_store_entry_14                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[14])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[14])    ,
     .cache_selected     (store_cache_selected[14])   ,
     .cache_miss         (store_cache_miss[14])       ,
     .cache_hit          (store_cache_hit[14])        ,
     .ddr_selected       (store_ddr_selected[14])     ,
     .ddr_ack            (store_ddr_ack[14])          ,
     .dev_selected       (store_dev_selected[14])     ,
     .selected_WAW       (store_WAW_selected[14])     ,
     .flush_selected     (entry_flush_select[14])     ,
     .resp_selected      (store_resp_selected[14])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[14])      ,
     .dev_store_wready   (dev_store_wready[14])       ,
     .dev_store_bvalid   (dev_store_bvalid[14])       ,
     .entry_req_addr      (entry_req_addr_14)          ,
     .entry_req_id        (entry_req_id_14)            ,
     .entry_vld           (entry_vld_14)               ,
     .entry_req_state     (entry_req_state_14)         ,
     .entry_req_type      (entry_req_type_14)          ,
     .entry_store_data    (entry_store_data_14)        ,
     .entry_store_tag     (entry_store_tag_14)         ,
     .entry_req_info      (entry_req_info_14)          ,
     .entry_req_addr_o   (entry_req_addr_o_14)        ,
     .entry_req_id_o     (entry_req_id_o_14)          ,
     .entry_vld_o        (entry_vld_o_14)             ,
     .entry_req_state_o  (entry_req_state_o_14)       ,
     .entry_req_type_o   (entry_req_type_o_14)        ,
     .entry_store_data_o (entry_store_data_o_14)      ,
     .entry_store_tag_o  (entry_store_tag_o_14)       ,
     .entry_req_info_o   (entry_req_info_o_14)         
 );
                                                  
frv_store_entry inst_frv_store_entry_15                
 (                                                     
     .clk                (clk)                        ,
     .clk_en             (clk_en)                     ,
     .rst_n              (rst_n)                      ,
     .selected_in        (store_in_selected[15])      ,
     .selected_out       (selected_out)               ,
     .queue_forward      (rreq)                        ,
     .retire_vld         (retire_vld_selected[15])    ,
     .cache_selected     (store_cache_selected[15])   ,
     .cache_miss         (store_cache_miss[15])       ,
     .cache_hit          (store_cache_hit[15])        ,
     .ddr_selected       (store_ddr_selected[15])     ,
     .ddr_ack            (store_ddr_ack[15])          ,
     .dev_selected       (store_dev_selected[15])     ,
     .selected_WAW       (store_WAW_selected[15])     ,
     .flush_selected     (entry_flush_select[15])     ,
     .resp_selected      (store_resp_selected[15])    ,
     .load_resp          (load_resp_vld)              ,
     .dev_store_awready  (dev_store_awready[15])      ,
     .dev_store_wready   (dev_store_wready[15])       ,
     .dev_store_bvalid   (dev_store_bvalid[15])       ,
     .entry_req_addr      (entry_req_addr_15)          ,
     .entry_req_id        (entry_req_id_15)            ,
     .entry_vld           (entry_vld_15)               ,
     .entry_req_state     (entry_req_state_15)         ,
     .entry_req_type      (entry_req_type_15)          ,
     .entry_store_data    (entry_store_data_15)        ,
     .entry_store_tag     (entry_store_tag_15)         ,
     .entry_req_info      (entry_req_info_15)          ,
     .entry_req_addr_o   (entry_req_addr_o_15)        ,
     .entry_req_id_o     (entry_req_id_o_15)          ,
     .entry_vld_o        (entry_vld_o_15)             ,
     .entry_req_state_o  (entry_req_state_o_15)       ,
     .entry_req_type_o   (entry_req_type_o_15)        ,
     .entry_store_data_o (entry_store_data_o_15)      ,
     .entry_store_tag_o  (entry_store_tag_o_15)       ,
     .entry_req_info_o   (entry_req_info_o_15)         
 );
                                                  


















endmodule
